package com.dstz.demo.rest.controller;

import com.dstz.base.api.aop.annotion.CatchErr;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.PDiachronicRecordManager;
import com.dstz.demo.core.model.PDiachronicRecord;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.UUID;


/**
 * 历时保存记录 控制器类<br/>
 * @author  aschs
 * </pre>
 */
@RestController
@RequestMapping("/sys/pDiachronicRecord")
public class PDiachronicRecordController extends BaseController<PDiachronicRecord>{
	@Resource
	PDiachronicRecordManager pDiachronicRecordManager;
	
	
	@Override
	protected String getModelDesc() {
		return "历时保存记录";
	}


	@PostMapping("/insert")
	@CatchErr("添加失败")
	public ResultMsg insertPDiachronicRecord(@RequestBody PDiachronicRecord pDiachronicRecord){
		pDiachronicRecord.setPDiachronicRecordId(UUID.randomUUID().toString());
		pDiachronicRecord.setSavaTime(new Date());
		pDiachronicRecordManager.insertPDiachronicRecord(pDiachronicRecord);
		return getSuccessResult("添加成功");
	}

	@PostMapping("/delete")
	@CatchErr("删除失败")
	public ResultMsg deletePDiachronicRecord(String pDiachronicRecordId){
		pDiachronicRecordManager.deletePDiachronicRecord(pDiachronicRecordId);
		return getSuccessResult("删除成功");
	}

	@PostMapping("/select")
	@CatchErr("获取失败")
	public ResultMsg selectPDiachronicRecord(){
		List<PDiachronicRecord> list=pDiachronicRecordManager.seletePDiachronicRecordModel();
		ResultMsg resultMsg=new ResultMsg();
		resultMsg.setData(list);
		return resultMsg;
	}


}
